package com.osi.project.common.excaption;

import com.osi.project.common.enums.ProjectReturnCodeEnum;
import com.osi.start.common.business.exception.IBaseException;

/**
 * 异常基类
 *
 * @author osi
 * @date 2018年9月13日下午12:02:35
 */
public class ProjectBusinessException extends RuntimeException implements IBaseException {

	private static final long serialVersionUID = 1L;
	private Integer code;
	private String msg;
	private String error;

	public ProjectBusinessException() {
		super();
	}

	public ProjectBusinessException(String message) {
		super(message);
	}

	public ProjectBusinessException(Throwable e, ProjectReturnCodeEnum returnCodeEnum) {
		super(e);
		if (null == returnCodeEnum) {
			throw new IllegalArgumentException();
		}
		code = returnCodeEnum.getCode();
		msg = returnCodeEnum.getValue();
		error = e.getMessage();
	}

	public ProjectBusinessException(ProjectReturnCodeEnum returnCodeEnum) {
		super(returnCodeEnum.getValue());
		this.code = returnCodeEnum.getCode();
		this.msg = returnCodeEnum.getValue();
	}

	public ProjectBusinessException(ProjectReturnCodeEnum returnCodeEnum, String error) {
		super(returnCodeEnum.getValue());
		this.code = returnCodeEnum.getCode();
		this.msg = returnCodeEnum.getValue();
		this.error = error;
	}

	public ProjectBusinessException(Integer code, String msg) {
		super(msg);
		this.code = code;
		this.msg = msg;
	}

	public ProjectBusinessException(Integer code, String msg, String error) {
		super(msg);
		this.code = code;
		this.msg = msg;
		this.error = error;
	}

	@Override
	public Integer getCode() {
		return this.code;
	}

	@Override
	public String getMsg() {
		return msg;
	}

	@Override
	public String getError() {
		return error;
	}

}
